package team.seekers.hula.question.point.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.common.entity.VisibilityUpdateDTO;
import team.seekers.hula.question.point.entity.dto.PointQueryDTO;
import team.seekers.hula.question.point.entity.vo.PointManageListVO;
import team.seekers.hula.question.point.entity.dto.PointUpdateManageDTO;
import team.seekers.hula.question.point.service.PointManageService;

import java.util.List;

/**
 * @author Godc
 */
@Controller
@ApiResponseBody
@RequestMapping("/manage/point")
public class PointManageController {

    @Autowired
    private PointManageService pointManageService;

    @GetMapping("/delete")
    public void adminDelete(@RequestParam("PointId") String id){
        pointManageService.delete(id);
    }

    @PostMapping("/update/info")
    public void updateInfo(@RequestBody PointUpdateManageDTO updateVO){
        pointManageService.update(updateVO);
    }

    @PostMapping("/update/visibility")
    public void updateVisibility(@RequestBody VisibilityUpdateDTO updateDTO){
        pointManageService.updateVisibility(updateDTO);
    }

    @GetMapping("/list")
    public List<PointManageListVO> list(PointQueryDTO pointQuery){
        return pointManageService.list(pointQuery);
    }

    @GetMapping("/approveExamine")
    public void approveExamine(@RequestParam String id){
        pointManageService.changeApproval(id,1);
    }

    @GetMapping("/failedExamine")
    public void failedExamine(@RequestParam String id){
        pointManageService.changeApproval(id,2);
    }

}
